<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>

        <ui:composition template="./../template.xhtml">
            <ui:define name="meta">
                <c:if test="${user != null}">
                    <c:if test="${user.isAdmin == false}">
                        <meta http-equiv="refresh" content="0; URL=#{facesContext.externalContext.requestContextPath}/faces/403error.xhtml" />
                    </c:if>
                </c:if>
                <c:if test="${user == null}">
                    <meta http-equiv="refresh" content="0; URL=#{facesContext.externalContext.requestContextPath}/faces/login.xhtml" />
                </c:if>
            </ui:define>
            <ui:define name="title">
                Participate Event
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <p:fieldset legend="#{registrationController.currentEvent.eventName}" toggleable="true">

                        <p:panelGrid columns="2">
                            <p:column>
                                <h:outputText value="Registration Time: " />
                            </p:column>
                            <p:column>
                                <h:outputText value="#{registrationController.currentEvent.startReg}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                                <h:outputText value=" - " />
                                <h:outputText value="#{registrationController.currentEvent.endReg}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </p:column>
                            <p:column>
                                <h:outputText value="Event Time: " />
                            </p:column>
                            <p:column>
                                <h:outputText value="#{registrationController.currentEvent.startEvent}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                                <h:outputText value=" - " />
                                <h:outputText value="#{registrationController.currentEvent.finishEvent}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </p:column>
                            <p:column>
                                Max Player
                            </p:column>
                            <p:column>

                                <h:outputText value="#{registrationController.currentEvent.maxPlayer}"/>
                            </p:column>

                        </p:panelGrid>
                    </p:fieldset>

                    <p:dataTable var="item" value="#{registrationController.itemsRegEvt}"
                                 paginator="true" rows="10"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                 rowsPerPageTemplate="5,10,15"
                                 style="font-size: 12px;">
                        <p:column style="width: 120px;" sortBy="#{item.userInfo.userName}" filterBy="#{item.userInfo.userName}">
                            <f:facet name="header">
                                <h:outputText value="UserName"/>
                            </f:facet>
                            <h:outputText value="#{item.userInfo.userName}" />
                        </p:column>
                        <p:column style="width: 120px;">
                            <f:facet name="header">
                                <h:outputText value="Reg Time"/>
                            </f:facet>
                            <h:outputText value="#{item.regTime}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>
                        <p:column style="width: 120px;">
                            <f:facet name="header">
                                <h:outputText value="Status Reg"/>
                            </f:facet>
                            <h:outputText value="#{item.statusReg}" />
                        </p:column>
                        <p:column style="width: 120px;">
                            <f:facet name="header">
                                <h:outputText value="Action"/>
                            </f:facet>
                            <!-- handler action if Event has not started yet -->
                            <c:if test="#{!registrationController.checkStartTimeEvt()}">
                                <!-- Accpet button : regAcceptPlayer < MaxPlayer , StatusReg != Accept -->
                                <p:commandButton icon="ui-icon-check"  ajax="false"
                                                 action="#{registrationController.setStatusAccept}"
                                                 rendered="#{!registrationController.isMaxPlayer() and !(item.statusReg eq 'Accept')}"
                                                 value="Accept"/>
                                <!-- Accpet button : StatusReg != Cancel -->
                                <p:commandButton icon="ui-icon-close" ajax="false" value="Cancel"
                                                 action="#{registrationController.setStatusCancel}"
                                                 rendered="#{!(item.statusReg eq 'Cancel')}"/>
                            </c:if>

                            <h:outputText style="font-weight: bold;color: blue;" value="Event has been started"
                                          rendered="#{registrationController.checkStartTimeEvt()}"/>
                        </p:column>
                    </p:dataTable>
                    <p:commandButton icon="ui-icon ui-icon-print" ajax="false" value="View list"
                                                 action="ListParticipateAccept"/>
                </h:form>




            </ui:define>

        </ui:composition>

    </body>
</html>
